package com.sig;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import android.os.Environment;
import android.util.Log;

public class LecteurFichier {

	public static String readFileFromSDCard(String nom) {
		StringBuilder builder = new StringBuilder();

		File directory = Environment.getExternalStorageDirectory();
		File file = new File(directory + "/sig/"+nom);
		
		Log.d("FILE",file.getAbsolutePath());
		
		if (file.exists()) {

			Log.e("Testing", "Starting to read");
			BufferedReader reader = null;
			try {
				reader = new BufferedReader(new FileReader(file));

				String line;
				while ((line = reader.readLine()) != null) {
					builder.append(line);
				}
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				if (reader != null) {
					try {
						reader.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
			}
		}else
			Log.d("FILE","file "+nom+" not found");
		
		return builder.toString();
	} 

}
